package com.zmzncs.lmtc.module.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmzncs.lmtc.common.pojo.Rest;
import com.zmzncs.lmtc.module.system.dao.UserMapper;
import com.zmzncs.lmtc.module.system.pojo.user.User;
import com.zmzncs.lmtc.module.system.pojo.user.UserDTO;
import com.zmzncs.lmtc.module.system.pojo.user.UserSearchFrom;
import com.zmzncs.lmtc.module.system.pojo.user.UserUpdateFrom;
import com.zmzncs.lmtc.module.system.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 任建波
 * @since 2019-09-10
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 修改用户
     */
    @Override
    @Transactional
    public Rest updateUser(UserUpdateFrom userUpdateFrom) {
        User user = new User();
        BeanUtils.copyProperties(userUpdateFrom, user);
        // 修改用户
        userMapper.updateById(user);

        return null;
    }

    /**
     * 获取人员列表
     */
    @Override
    public IPage<UserDTO> getUserList(UserSearchFrom form) {
        IPage iPage = userMapper.getUserList(form.getPage(), form);
        return iPage;
    }
}
